import request from "@/utils/request";
// 配置公共的header
const headers = {
  "Content-Type": "application/json;charset=utf-8"
};
/**
 * @name login
 * @description 登录方法
 * @param { userCode, password }
 * @author cjs1992
 * @date 2019-09-04 08:41:13
 */
export function login(data) {
  return request({
    url: "/web/user/login",
    method: "post",
    data: data,
    ...headers
  });
}
/**
 * @name getMenu
 * @description 获取菜单
 * @author cjs1992
 * @date 2019-09-04 09:49:40
 */
export function getMenu(data = {}) {
  return request({
    url: "/web/menu/loadMenu",
    method: "post",
    data: data,
    ...headers
  });
}
/**
 * @name logout
 * @description 登出
 * @author cjs1992
 * @date 2019-09-04 10:12:19
 */
export function logout(data = {}) {
  return request({
    url: "/web/user/logout",
    method: "get",
    data: data
  });
}
/**
 * @name checkLogin
 * @description 检验是否登录
 * @author cjs1992
 * @date 2019-09-12 09:55:59
 */
export function checkLogin() {
  return request({
    url: "/web/user/checkLogin",
    method: "get"
  });
}
/**
 * @name getMenu
 * @description 获取菜单
 * @author cjs1992
 * @date 2019-09-27 14:28:55
 */
export function getRoutes(data = {}) {
  return request({
    url: "/web/sysPermission/all",
    method: "get",
    params: data
  });
}
export function getInfo(token) {
  return request({
    url: "/user/info",
    method: "get",
    params: { token }
  });
}
/**
 * @name changeMenu
 * @description 切换用户角色
 * @param {
 *  roleId
 * }
 * @author cjs1992
 * @date 2019-12-04 09:39:43
 */
export function changeMenu(data = {}) {
  return request({
    url: "/web/menu/changeMenu",
    method: "get",
    params: data
  });
}
/**
 * @name getSysInfos
 * @description 获取所部署的学工系统
 * @author cjs1992
 * @date 2020-02-11 12:00:25
 */
export function getSysInfos(data = {}) {
  return request({
    method: "get",
    url: "/web/sysDict/getDictByBzdm",
    params: data
  });
}
/**
 * @name getCurrentUserAndDept
 * @description 获取当前用户和部门
 * @param {}
 * @return {}
 * @author cjs1992
 * @date 2020-11-03 11:36:54
 */
export function getCurrentUserAndDept(data = {}, config = {}) {
  return request({
    method: "get",
    url: "/web/user/getCurrentUserAndDept",
    params: data,
    ...config
  });
}
import requestUnimall from "@/utils/request-unimall.js";
import Qs from "qs";
export function listUser(query) {
  return requestUnimall({
    method: 'get',
    url: "/web/admin-user/list",
    params: {
      // _gp: 'admin.user',
      // _mt: 'list',
      ...query
    }
  })
}

export function activeUser(data) {
  return requestUnimall({
    method: 'post',
    url: "/web/admin-user/edit-status",
    data: Qs.stringify({
      // _gp: 'admin.user',
      // _mt: 'editStatus',
      userId: data.id,
      status: data.status
    })
  })
}

export function createUser(data) {
  return requestUnimall({
    method: 'post',
    url: "/web/admin-user/create",
    data: Qs.stringify({
      // _gp: 'admin.user',
      // _mt: 'create',
      user: JSON.stringify(data)
    })
  })
}

export function updateUser(data) {
  return requestUnimall({
    method: 'post',
    url: "/web/admin-user/edit",
    data: Qs.stringify({
      // _gp: 'admin.user',
      // _mt: 'edit',
      user: JSON.stringify(data)
    })
  })
}

export function deleteUser(id, nickname) {
  return requestUnimall({
    method: 'post',
    url: "/web/admin-user/delete",
    data: Qs.stringify({
      // _gp: 'admin.user',
      // _mt: 'delete',
      id: id
    })
  })
}
